package com.blb.ioc.demo1;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Spring XML配置
 * ClasspathXmlApplicationContext
 * FileSystemXmlApplicationContext
 */
public class ComputerXmlTest {

    public static void main(String[] args) {
        //创建IOC容器
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        //从IOC容器获得对象 重载 String 对象id ，Class 类型
//        Computer computer = (Computer) context.getBean("computer");
        Computer computer = context.getBean(Computer.class);
        computer.start();

        Computer computer2 = context.getBean(Computer.class);
        Computer computer3 = context.getBean(Computer.class);
        System.out.println(computer == computer2);
        System.out.println(computer3 == computer2);
    }
}
